function ajax(url,type='get',data={},success,err) {
	let xhr = new XMLHttpRequest();

	let arr =[];
	for(let key in data){
		arr.push(`${key}=${data[key]}`)
	}
	let strData = arr.join('&');
	if(type=='POST'){
		xhr.open('POST',url,true);
		xhr.setRequestHeader('content-type','application/x-www-form-urlencoded');
		xhr.send(strData)
	}else{
		xhr.open('GET',url+'?'+strData,true);
		xhr.send()
	}
	xhr.onreadystatechange =function () {
		if(xhr.readyState==4){
			if(xhr.status==200){
				success&&success(xhr.responseText)
			}else{
				error&&error();
			}
		}
	}

}